/**
 * @Project TMHSCFX
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Apr 14, 2011
 * @Createtime 4:08:11 PM
 */

package com.tmh.study.fAS3AMTM.chap5
{
	import flash.display.Sprite;
	import flash.events.Event;

	public class Acceleration1 extends Sprite
	{
		private var ball:Ball;

		private var vx:Number = 0;

		private var ax:Number = .2;

		public function Acceleration1()
		{
			super();
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		}

		private function addedToStageHandler(event:Event):void
		{
			initData();
		}

		private function initData():void
		{
			ball = new Ball();
			addChild(ball);
			ball.x = 50;
			ball.y = 100;
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		private function onEnterFrame(event:Event):void
		{
			vx += ax;
			ball.x += vx;
		}
	}
}